package com.yq.interview.jvm.study;

import java.lang.ref.WeakReference;

/**
 * @ClassName WeakReferenceDemo
 * @Description 弱引用
 * @Author yaoqiang
 * @Date 2020/11/25 11:24
 * @Version 1.0
 */
public class WeakReferenceDemo {
    public static void main(String[] args) {
        Object o1=new Object();
        WeakReference weakReference=new WeakReference(o1);
        System.out.println(o1);
        System.out.println(weakReference);
        o1=null;
        System.gc();
        System.out.println("....................");
        System.out.println(o1);
        System.out.println(weakReference.get());
    }
}
